import java.util.Arrays;

class Solution {
    int[] memo;
    public int lengthOfLIS(int[] nums) {
        int ret = 0;
        int n = nums.length;
        memo = new int[n];
        for(int i = 0; i<n; i++) {
            ret = Math.max(ret,dfs(i,nums));
        }
        return ret;
    }
    public int dfs(int pos, int[] nums) {
        if(memo[pos]!=0) return memo[pos];
        int ret = 1;
        for(int i = pos+1; i<nums.length; i++) {
            if(nums[i] > nums[pos]) {
                ret = Math.max(ret,dfs(i,nums)+1);
            }
        }
        memo[pos] = ret;
        return ret;
    }
}

public class Test {
}
